﻿using System.Collections.Generic;
using System.Web.Mvc;
using VirtuosoDal.Config;
using VirtuosoDal.Entities;
using ViewType = AspNetMvc.Entities.EventViewType;

namespace AspNetMvc.Models
{
    public class EventForEditing
    {
        public Event Event { get; set; }

        public string StartDateString
        {
            get
            {
                return Event.StartDateTimeOffset.ToString(DateTimeFormats.DateFormat);
            }
        }
        public List<SelectListItem> StartHoursList;
        public List<SelectListItem> StartMinutesList;

        public string EndDateString
        {
            get
            {
                if (!Event.EndDateTimeOffset.HasValue)
                    return string.Empty;

                return Event.EndDateTimeOffset.Value.ToString(DateTimeFormats.DateFormat);
            }
        }
        //ToDo: Move List filling inside the entity ?
        public List<SelectListItem> EndHoursList { get; set; }
        public List<SelectListItem> EndMinutesList { get; set; }

        public List<SelectListItem> EventTypesList { get; set; }
        public List<List<SelectListItem>> EventCategoriesLists { get; set; }

        public Dictionary<EventPropertyDescription, List<string>> TypePropertiesForView { get; set; }
        public Dictionary<string, Dictionary<EventPropertyDescription, List<string>>> CategoriesPropertiesForView { get; set; }

        public ViewType ViewType { get; set; }
        public string OperationName { get; set; }
        public string OperationButtonCaption { get; set; }

        public EventForEditing(Event @event)
        {
            Event = @event;

            EventCategoriesLists = new List<List<SelectListItem>>();

            TypePropertiesForView = new Dictionary<EventPropertyDescription, List<string>>();
            CategoriesPropertiesForView = new Dictionary<string, Dictionary<EventPropertyDescription, List<string>>>();
        }
    }
}